<?php
namespace app\api\model;
/** 
* Document
*/
class Banner extends Base {
    protected $hidden =['update_time','delete_time'];
    
    public function items(){
        return $this->hasMany('BannerItem','banner_id','id');
    }
    
    public static function getBannerById($id){
        $banner = self::get($id,['items']);
        if (empty($banner)) return [];
        $bannerDate = $banner->toArray();
        foreach ($bannerDate['items'] as &$v) {
            $v['img_url'] = Image::getImgUrl($v['img_id']);
        }
        return $bannerDate;
    }
}